package com.dhnsoft.shortLink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dhnsoft.shortLink.project.dao.entity.LinkNetworkStatsDO;
import com.dhnsoft.shortLink.project.dto.req.ShortLinkStatsReqDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface LinkNetworkStatsMapper extends BaseMapper<LinkNetworkStatsDO> {
    @Insert("insert into t_link_network_stats(full_short_url,gid,date,cnt,network,create_time,update_time,del_flag)" +
            "values(#{linkNetworkStatsDO.fullShortUrl},#{linkNetworkStatsDO.gid},#{linkNetworkStatsDO.date},#{linkNetworkStatsDO.cnt}" +
            ",#{linkNetworkStatsDO.network},now(),now(),0)ON DUPLICATE KEY UPDATE cnt=cnt+#{linkNetworkStatsDO.cnt}," +
            "update_time=now()")
    void linkNetworkStatsDO(@Param("linkNetworkStatsDO") LinkNetworkStatsDO linkNetworkStatsDO);

    List<LinkNetworkStatsDO> listNetworkStatsByShortLink(@Param("param") ShortLinkStatsReqDTO requestParam);
}

